package net.neptech.config;

import com.alibaba.nls.client.protocol.NlsClient;
import jakarta.annotation.PreDestroy;
import net.neptech.factory.NlsClientFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NlsClientConfig {
    @Value("${aliyun.access-key-id}")
    private String akId;
    @Value("${aliyun.access-key-secret}")
    private String akSecret;

    @Bean
    public NlsClient nlsClient() {
        return NlsClientFactory.getClient(akId, akSecret);
    }

    @PreDestroy
    public void destroy() {
        NlsClientFactory.shutdown();
    }
}